package com.seventh.parkingrent.controller;


import com.seventh.parkingrent.common.Result;
import com.seventh.parkingrent.domain.Record;
import com.seventh.parkingrent.service.IRecordService;
import com.seventh.parkingrent.service.impl.RecordServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-08-27
 */
@RestController
@Slf4j
@CrossOrigin("*")
public class RecordController {

    @Resource
    private IRecordService recordService;

    @GetMapping("/findRecord")
    public Result findRecord(int userId){
        log.info("userId{}",userId);
        List<Record> records = recordService.findRecord(userId);
        return Result.success(records);
    }

    @GetMapping("createwelltorder")
    public Result createwelltorder(Double money,Integer id){
        log.info("充值得到充值金额:{},用户id:{}",money,id);
        Integer welltorderid = recordService.topUp(money, id);
        return Result.success(welltorderid);
    }


}

